package com.nxy.cpfsfe.enumtype;

import java.lang.reflect.Method;
import java.util.Map;
import com.adtec.starring.exception.BaseException;
import com.nxy.cpfsfe.busi.bbatproc.NCSDlFNtcProcSrvBean;

/**
 * Description：NCS文件类型枚举
 * 
 * @author jjw
 *
 */
public enum NCSFileTypEnum {
	
	CHKA_F("ET01","对账文件","chkAFProcess"),
	BIZ_TYP_AND_KND_MNG("ET04","业务类型和种类管理","nonDeal"),
	SYS_PARM_UPDT_NTC("ET05","系统参数变更通知","nonDeal"),
	BKNM_BKNO_UPDT_F("ET06","行名行号变更文件","nonDeal"),
	CRDBIN_AND_BKNO_RELATSH_UPDT_F("ET07","卡BIN与行号对照关系变更文件","nonDeal"),
	BIL_LIST("ET08","计费清单","nonDeal"),
	O_C_AUTH_UPDT_F("ET09","机构渠道权限变更文件","nonDeal"),
	BIZ_AUTH_UPDT_NTC("ET10","业务权限变更通知","nonDeal"),
	OTS_F("ET11","其他文件","nonDeal"),
	CRCRD_CHKA_F("ET12","信用卡对账文件","nonDeal"),
	CUP_AGNT_CLRG_F("ET13","银联代理清算文件","nonDeal");
	
	private String code;
	
	private String name;
	
	private String processMethod;
	
	NCSFileTypEnum(String code,String name,String processMethod){
		this.code = code;
		this.name = name;
		this.processMethod = processMethod;
	}
	
	public String getCode() {
		return code;
	}

	public String getName() {
		return name;
	}

	public String getProcessMethod() {
		return processMethod;
	}

	public static String getNameByCode(String code){
		NCSFileTypEnum[] enums = NCSFileTypEnum.values();
		for(NCSFileTypEnum item : enums){
			if(item.getCode().equals(code)){
				return item.getName();
			}
		}
		return null;
	}
	
	public static Method getProcMethodByCode(String code){
		NCSFileTypEnum[] enums = NCSFileTypEnum.values();
		for(NCSFileTypEnum item : enums){
			if(item.getCode().equals(code)){
				String processMethodNm = item.getProcessMethod();
				
				try {
					return NCSDlFNtcProcSrvBean.class.getDeclaredMethod(processMethodNm, Map.class);
				} catch (Exception e) {
					String errMsg = String.format("获取[%s]-[%s]的处理方法[%s]失败", item.getCode(),item.getName(),item.getProcessMethod());
					throw new BaseException(RespCd.NCPO6804,e,errMsg);
				}
			}
		}
		
		String errMsg = String.format("NCS文件类型[%s]无对应处理方法", code);
		throw new BaseException(RespCd.NCPS2001,errMsg);
		
	}

}
